﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using HA.MT3DMS.FileLayer;

namespace HA.MT3DMS.DomainLayer
{
    
    [Serializable]
    public class Dispersion:MTPackage,ICloneable
    {
        public Dispersion()
        {
          


        }
        protected List<double[,]> _AL = new List<double[,]>();//模型网格中每个单元的纵向分散性，αL（单位为升（L））
        /// <summary>
        /// 模型网格中每个单元的纵向分散性，αL（单位为升（L））
        /// </summary>
        public  List<double[,]> AL
        {
            get { return _AL; }
            set { _AL = value; }
        }
       
        private List<DispersionChild> _DisperChild = new List<DispersionChild>();

        public List<DispersionChild> DisperChild
        {
            get { return _DisperChild; }
            set { _DisperChild = value; }
        }

        public void OnGridReset(int nrows,int ncols,int nlayers)
        {
            this._DisperChild.Clear();


            this._AL.Clear();


            for (int i = 0; i < nlayers; i++)
            {
                DispersionChild dc = new DispersionChild();

                this._DisperChild.Add(dc);


                double[,] al=new double[nrows,ncols];


                this._AL.Add(al);

                
            }




           
 
        }

        public void SetAL(List<double[,]> Als)
        {          
            for (int i = 0; i < this.AL.Count; i++)
            {
                this.AL[i] = Als[i];
            }
        }




        public object Clone()
        {
            Dispersion obj = new Dispersion();
            obj =(Dispersion) this.MemberwiseClone();
            List<DispersionChild> dis = new List<DispersionChild>();
            for (int i = 0; i < this.DisperChild.Count; i++)
            {
                DispersionChild di = new DispersionChild();
                di.DMCOEF = this.DisperChild[i].DMCOEF;
                di.TRPT = this.DisperChild[i].TRPT;
                di.TRPV = this.DisperChild[i].TRPV;
                dis.Add(di);
            }
            obj.DisperChild = dis;
            return obj;
        }



        public DispersionPack ToPack()
        {
            DispersionPack Dis = new DispersionPack();
            Dis.AL = this.AL;
            Dis.TRPV.Clear();
            Dis.TRPT.Clear();
            Dis.DMCOEF.Clear();
            foreach (DispersionChild dis in this.DisperChild)
            {
                Dis.TRPT.Add(dis.TRPT);
                Dis.TRPV.Add(dis.TRPV);
                Dis.DMCOEF.Add(dis.DMCOEF);
            }

            return Dis;
        }

    }
[Serializable ]
    public class DispersionChild
    {
        private int _Index;
        /// <summary>
        /// 序号
        /// </summary>
        public int Index
        {
            get { return _Index; }
            set { _Index = value;  }

           
        }

        private double _TRPT=1;
        /// <summary>
        /// 一组一维数组，定义水平横向分散性αTH和纵向分散性αL的比值。
        /// 数组中每个数值对应模型的一层。
        /// 近期的一些实地考察建议TRPT一般不会大于0.1
        /// 默认值0.1
        /// </summary>
        public double TRPT
        {
            get { return _TRPT; }
            set { _TRPT = value; }
        
        }
        private double _TRPV=1;
        /// <summary>
        /// 竖直横向分散性αTV和纵向分散性αL的比值。
        /// 数组中每个数值对应模型的一层。
        /// 近期的一些实地考察建议TRPT一般不会大于0.01。
        /// 默认值0.01
        /// </summary>
        public double TRPV
        {
            get { return _TRPV; }
            set { _TRPV = value; }
        }

        private double _DMCOEF;
        /// <summary>
        /// 有效分子扩散系数（单位为L2T-1）。如果分子扩散效应不重要，设DMCOEF=0。数组中每个数值对应模型的一层。	
        /// 默认值0
        /// </summary>
        public double DMCOEF
        {
            get { return _DMCOEF; }
            set { _DMCOEF = value; }
        }

      
       
    }
}
